#include <iostream>
#include <string>
#include "head.h"

using namespace std;

void Demo1()
{
    try{
        throw 1;
    } catch(char c) {
        cout << "catch(char c) = " << c << endl;
    } catch(short c) {
        cout << "catch(short c) = " << c << endl;
    } catch(double c) {
        cout << "catch(double c) = " << c << endl;
    } catch(int c) {
        cout << "catch(int c) = " << c << endl;
    } catch(...) {
        cout << "none catch in Demol!" << endl;
    }
}

void Demo2()
{
    throw "Hello try";
}
void exception_handle_test(void)
{
    Demo1();

    try{
        Demo2();
    } catch(const char* s) {
        cout << "catch(const char* s) = " << s << endl;
    } catch(string s) {
        cout << "catch(string s) = " << s << endl;
    } catch(...) {

    }
}

void exception_test(void)
{
    try{
        try{
            throw 0;
        } catch(int i) {
            cout << "Inter: catch(int i)" << endl;
            throw i;
        } catch(...) {
            cout << "Inter : catch(...)!" << endl;
            throw;
        }
    } catch(...) {
        cout << "Outer: catch(...)" << endl;
    }
}
